﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
using QLKH.PopUp.Baocao;

namespace QLKH.View.Baocao
{
    public partial class dsSudung0 : UserControl
    {
        DataView view = new DataView();
        public dsSudung0()
        {
            InitializeComponent();
        }

        private void dsSudung0_Load(object sender, EventArgs e)
        {
            clSudung clsd = new clSudung();
            DataTable dtsd = clsd.getDataBatthuong(Int16.Parse(DateTime.Now.Month.ToString()), Int16.Parse(DateTime.Now.Year.ToString()),Int16.Parse("30"),"<");

            dataGrid.AutoGenerateColumns = false;
            dataGrid.DataSource = view = dtsd.DefaultView;
        }

        public void TimKiem(string txtsearch, string type, Int16 id)
        {
            string querySearch = "1=1";
            if (txtsearch.Length > 0)
                querySearch += " and (maCu LIKE '%" + txtsearch + "%')";
            if (id > 0)
            {
                if (type == "D")
                    querySearch += " and idDuong = " + id + " and idDHTong = 0";
                else
                    querySearch += " and idDHTong = " + id;
            }
            view.RowFilter = querySearch;
        }

        private void tool_search_Click(object sender, EventArgs e)
        {
            popTimkiem usfritem = new popTimkiem();
            // ké thằng GetValue của form1 vào form2
            usfritem.MyGetData = new popTimkiem.TimKiem(TimKiem);
            usfritem.ShowDialog();
        }
    }
}
